<?php
namespace app\validate;

use think\Validate;

class OrderCommentValidate extends Validate
{
    // 定义验证规则
    protected $rule = [
        'order_id' => 'require|integer',
        'star' => 'require|integer|min:0|max:5',
        'text' => 'require|max:500',
    ];

    // 定义提示信息
    protected $message = [
        'order_id.require' => '请选择评价订单',
        'order_id.integer' => '订单ID参数格式错误',
        'star.require' => '请评星',
        'star.integer' => '评星参数格式错误',
        'star.min' => '评星参数格式错误',
        'star.max' => '评星参数格式错误',
        'text.require' => '请填写评价',
        'text.max' => '评价最多500个字符',
    ];

    // 定义验证场景
    protected $scene = [
        'comment' => ['order_id', 'star', 'text']
    ];
}
